package com.hx.quartz.task;

import com.hx.common.utils.StringUtils;
import com.hx.resource.domain.FileShare;
import com.hx.resource.service.IFileShareService;
import org.apache.poi.hssf.record.DateWindow1904Record;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * 定时任务调度测试
 */
@Component("ryTask")
public class RyTask {
    @Autowired
    IFileShareService fileShareService;
    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
    }

    public void ryParams(String params) {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams() {
        List<FileShare> fileShares = fileShareService.selectFileShareList(null);
        fileShares.forEach((o)->{
            Date shareTime = o.getShareTime();
            Date nowTime = new Date();
            long now = nowTime.getTime();
            long effectiveTime = shareTime.getTime() + o.getEffectiveTime() * 24 + 60 * 60 * 1000;
            if (now - effectiveTime >=0) {
                fileShareService.deleteFileShareById(o.getId());
            }
        });
    }



}
